﻿//

#include <iostream>
#include "../../win_com/xx_inline_hook.hpp"
#include "windows.h"

void func1() {
	printf("func1\n");
}
void func2() {
	printf("func2\n");
}

void test_hook_my_func() {
	func1();

	DWORD old_pro = 0;
	BOOL ret = VirtualProtect(&func1, 4096, PAGE_EXECUTE_READWRITE, &old_pro);
	xx_setjmp(&func1, &func2);

	func1();
}
//////////////////////
static __inline time_t __CRTDECL my_time(
	_Out_opt_ time_t* const _Time
) {
	return 1234;
}

void test_hook_cfunc() {
	printf("time=%u\n",time(NULL));

	DWORD old_pro = 0;
	BOOL ret = VirtualProtect(&time, 4096, PAGE_EXECUTE_READWRITE, &old_pro);
	xx_setjmp(&time, &my_time);

	printf("time=%u\n", time(NULL));

}

int main()
{
	test_hook_my_func();
	test_hook_cfunc();
	return 0;
}


